﻿if (!yxSoft)
    var yxSoft = {};

function PageOnLoad() {
    var str = document.getElementById("strHid").value;
    if (str != null && str != "") {
        var x = str.split("*")[0];
        var y = str.split("*")[1];
        MapControl.centerAndZoom(new Point(x, y), 17);
        DrawPoint(x + "," + y);
    }
    else {
        MapControl.centerAndZoom(new Point("104.0096","30.6734"), 15);
    }
    Mark();
}

function Mark() {
    var dataInputx, dataInputy;

    MapControl.changeDragMode('drawPoint', dataInputx, dataInputy, DrawPoint);
}

//在Map上添加点
function DrawPoint(pointStr, callbackfunction) {

    var point = new Point(pointStr.split(',')[0], pointStr.split(',')[1]);
    var pIcon = new Icon(); // 构造一个图标类
    pIcon.image = "Images/ding.png";
    pIcon.height = 43;
    pIcon.width = 49;
    var strMsg = "msg";
    var marker = new Marker(point, pIcon);  // 构造一个标记叠加对象
    marker.addListener("click", callbackfunction);   // 添加点击事件的响应
    MapControl.clearOverlays();
    MapControl.addOverlay(marker); // 将标记叠加对象添加到地图中
    displayform(point.x, point.y);
}

function displayform(x, y) {
    window.parent.document.getElementById('AddressX').value = x;
    window.parent.document.getElementById('AddressY').value = y;
}

function ViewEntire(_maxx, _minx, _maxy,_miny) {

    if (_minx == null || _maxx == null || _maxy == null || _maxy == null) {
        _minx = 103.892109;
        _miny = 30.649067;
        _maxx = 104.086843;
        _maxy = 30.726951;
    }
    MapControl.centerAtMBR(_minx, _miny, _maxx, _maxy);
}
//地图基本操作

function SetZoomInAction() {

    MapControl.zoomInExt();
}

function SetZoomOutAction() {

    MapControl.zoomOutExt();
}

function SetPanAction() {
    MapControl.changeDragMode('pan');
}
//显示辖区
function MapChoose(name) {
    var XMax = null;
    var XMin = null;
    var YMax = null;
    var YMin = null;
    switch (name) {
        case 'qingyangqu':
            XMax = 104.086843;
            XMin = 103.892109;
            YMax = 30.726951;
            YMin = 30.649067;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'caoshi':
            XMax = 104.08326;
            XMin = 104.062995;
            YMax = 30.680902;
            YMin = 30.669264;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'caotang':
            XMax = 104.045002;
            XMin = 104.021075;
            YMax = 30.671385;
            YMin = 30.653287;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'dongpo':
            XMax = 104.007341;
            XMin = 103.983301;
            YMax = 30.676321;
            YMin = 30.654781;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'funan':
            XMax = 104.035558;
            XMin = 104.007341;
            YMax = 30.686092;
            YMin = 30.669905;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'guanghua':
            XMax = 104.02739;
            XMin = 104.005528;
            YMax = 30.674811;
            YMin = 30.6533;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'huangtian':
            XMax = 103.980182;
            XMin = 103.9367;
            YMax = 30.72695;
            YMin = 30.68458;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'huangwa':
            XMax = 104.058336;
            XMin = 104.044051;
            YMax = 30.677659;
            YMin = 30.660561;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'jinsha':
            XMax = 104.013779;
            XMin = 103.988592;
            YMax = 30.700843;
            YMin = 30.674811;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'supo':
            XMax = 104.001314;
            XMin = 103.95004;
            YMax = 30.708199;
            YMin = 30.657409;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'taisheng':
            XMax = 104.087221;
            XMin = 104.068219;
            YMax = 30.675147;
            YMin = 30.661621;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'wangjia':
            XMax = 104.063676;
            XMin = 104.042161;
            YMax = 30.665163;
            YMin = 30.65004;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'wenjia':
            XMax = 103.961271;
            XMin = 103.892107;
            YMax = 30.724319;
            YMin = 30.660467;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'xiyu':
            XMax = 104.068302;
            XMin = 104.057963;
            YMax = 30.673941;
            YMin = 30.658774;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
        case 'xinhua':
            XMax = 104.0694;
            XMin = 104.050252;
            YMax = 30.685261;
            YMin = 30.671583;
            ViewEntire(XMax, XMin, YMax, YMin);
            break;
    }

}